#!/bin/bash

# 安装 Docker
sudo yum install -y yum-utils

sudo yum-config-manager \
    --add-repo \
    https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

# 配置 Docker 镜像
sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://cpw4gqgu.mirror.aliyuncs.com"]
}
EOF

# 启动 Docker 并设置开机启动
sudo systemctl daemon-reload
sudo systemctl start docker

# Docker 拉取镜像
sudo docker pull mysql:8.0.18
sudo docker pull node
sudo docker pull mcr.microsoft.com/dotnet/runtime:8.0

# 拉取入口引擎运维工具并构建镜像
sudo git clone https://gitee.com/yamiwamiyu/entry-engine-linux.git /opt/ee-launcher
sudo docker build -f Dockerfile-运维工具web -t ee-launcher-web /opt/ee-launcher

# 启动 MySQL 服务，mysql 卷最终挂载到了系统盘的什么位置可以通过 df 查看
sudo docker run -d -v mysql:/var/lib/mysql --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:8.0.18
# 启动入口引擎的服务
sudo docker run --restart=always -d -v /opt/ee-launcher/Server:/app --name ee-launcher-server -p 30001:30001 -p 33257:33257 mcr.microsoft.com/dotnet/runtime:8.0 bash -c "cd /app && dotnet LauncherServer.dll"
sudo docker run --restart=always -d -v /opt/ee-launcher/Client:/app --name ee-launcher-client mcr.microsoft.com/dotnet/runtime:8.0 bash -c "cd /app && dotnet LauncherClient.dll"
sudo docker run --restart=always -d -v --name ee-launcher-web -p 3000:3000 ee-launcher-web


# 安装 Dotnet8.0 运行时
```
# 注册 Microsoft 软件仓库
wget https://packages.microsoft.com/config/centos/8/packages-microsoft-prod.rpm -O packages-microsoft-prod.rpm
sudo rpm -ivh packages-microsoft-prod.rpm

# 拉取 SDK 或运行时
#sudo yum install dotnet-sdk-8.0
sudo yum install dotnet-runtime-8.0

# 但是任然会报错，暂时不想搞了
# dotnet: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by dotnet)
# dotnet: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by dotnet)
```